package com.ljc.cjgl.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ljc.cjgl.entitiy.TbClass;
import com.ljc.cjgl.service.ClassService;
import com.ljc.cjgl.service.TestRegisterService;

@Controller
@RequestMapping(value="/gradeTable")
public class GradeTableController {
	@Autowired
	private TestRegisterService service;
	@Autowired
	private ClassService classService;
	
	@RequestMapping(value="/first")
	public String first(ModelMap map) {
		List<String> xqs=service.getTestXq();
		List<TbClass> classes=classService.findAll();
		map.put("xqs", xqs);
		map.put("classes",classes);
		return "gradeTable/first";
	}
	
	@RequestMapping(value="/summarizing")
	public String summarizing(Integer classId,String xq,ModelMap map) {
		String bjm=classService.findById(classId).getName();
		String caption=bjm+xq+"成绩汇总表";
		List<String> ths=service.getths(classId,xq);
		List<List<Object>> grades=service.getGradsBy(classId,xq);
		map.put("className",bjm);
		map.put("xq",xq);
		map.put("caption", caption);
		map.put("ths",ths);
		map.put("grades",grades);
		return "gradeTable/summarizing";
	}
}
